home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17047 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: ix.netcom.com!news
  2. From: clahey@ix.netcom.com(Chris Lahey )
  3. Newsgroups: comp.lang.c++
  4. Subject: how to redirect ostream output
  5. Date: 12 Apr 1996 22:13:20 GMT
  6. Organization: Netcom
  7. Message-ID: <4kmki0$19h@dfw-ixnews2.ix.netcom.com>
  8. NNTP-Posting-Host: dgr-il3-23.ix.netcom.com
  9. X-NETCOM-Date: Fri Apr 12  5:13:20 PM CDT 1996
  10.  
  11. I am using a vendor's logging class that allows me to log to any
  12. ostream I pass to it or by default it will log to stderr.  Rather than
  13. write to a specific file or output device, I would like to be able to
  14. recognize when a the string ends (by looking for a '\n') and then flush
  15. the buffer to a queue using a package we purchased.
  16.  
  17. We are having trouble finding exactly where we need to put this logic. 
  18. The ostream class does not have any virtual methods, so we thought that
  19. we should inherit from streambuf, since ostream's constructor is passed
  20. a streambuf.  We weren't sure where to put our logic, so we overrode
  21. all of streambuf's virtual functions with a single cout << "I'm here"
  22. statement and then called the underlying streambuf function. 
  23. Unfortunately we found that (at least in our implementation on AIX
  24. 4.1.x) none of the virtual functions were being called.  So my question
  25. is: 
  26.  
  27. Where can we put this logic that will recognize when a '\n' is written
  28. to the ostream so we can flush the current buffer to our queue using
  29. the queue API's?  If it is not by inheriting from ostream or streambuf,
  30. is there another class that we could inherit from to get the same
  31. results.
  32.  
  33. Any help would be appreciated.
  34.  
  35. Thanks in advance,
  36.  
  37. Chris Lahey
  38. CCC Information Services
  39. Chicago
  40. clahey@ix.netcom.com
  41.